home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / nroff~06.zoo / dev.c < prev    next >
C/C++ Source or Header  |  1992-07-16  |  14KB  |  330 lines

  1. static char *rcsid_dev_c="$Id: dev.c,v 1.2 1992/07/16 10:38:32 rosenkra Exp $";
  2.  
  3. /*
  4.  * $Log: dev.c,v $
  5.  * Revision 1.2  1992/07/16  10:38:32  rosenkra
  6.  * port to gcc, add tm,ie,el
  7.  *
  8.  */
  9.  
  10. /*
  11.  *    dev.c - handle special output devices.
  12.  *
  13.  *    adapted for atariST/TOS by Bill Rosenkranz 11/89
  14.  *    net:    rosenkra@convex.com
  15.  *    CIS:    71460,17
  16.  *    GENIE:    W.ROSENKRANZ
  17.  *
  18.  */
  19.  
  20. #undef NRO_MAIN                    /* extern globals */
  21.  
  22. #include <stdio.h>
  23. #include "nroff.h"
  24.  
  25.  
  26. /*------------------------------*/
  27. /*    dev_char        */
  28. /*------------------------------*/
  29. int dev_char (c1, c2, c)        /* returns num chars */
  30. REGISTER char    c1;            /* first char in escape */
  31. REGISTER char    c2;            /* second char in escape */
  32. REGISTER char  *c;            /* ascii char to return */
  33. {
  34.  
  35. /*
  36.  *    handle specific output devices.
  37.  *
  38.  *    this will eventually read \lib\term\tab* files, but for now, we just
  39.  *    use our ANSI/vt100 scheme. in future, main will call something to
  40.  *    read -Tname (tabname) file, which would initialize a table of c1c2
  41.  *    vs ascii char. this routine would then read that table and presumably
  42.  *    return a string rather than a single char.
  43.  */
  44.  
  45.     /*
  46.      *   special symbols
  47.      */
  48.     if (c1 == 'e' && c2 == 'm') {*c = '-'; return (2);}    /* long dash */
  49.     if (c1 == 'h' && c2 == 'y') {*c = ','; return (2);}    /* hyphen */
  50.     if (c1 == 'b' && c2 == 'u') {*c = '*'; return (2);}    /* bullet */
  51.     if (c1 == 's' && c2 == 'q') {*c = 0xef; return (2);}    /* square */
  52.     if (c1 == 'r' && c2 == 'u') {*c = '_'; return (2);}    /* rule */
  53.     if (c1 == 'u' && c2 == 'l') {*c = '^'; return (2);}    /* underrule */
  54.     if (c1 == 'o' && c2 == 'l') {*c = ';'; return (2);}    /* overrule */
  55.     if (c1 == 'r' && c2 == '2') {*c = 0x3f; return (2);}    /* thin rule */
  56.     if (c1 == 'u' && c2 == '2') {*c = 0x9d; return (2);}    /* thin underrule */
  57.     if (c1 == 'o' && c2 == '2') {*c = 0x40; return (2);}    /* thin overrule */
  58.     if (c1 == '1' && c2 == '4') {*c = 0xac; return (2);}    /* 1/4 */
  59.     if (c1 == '1' && c2 == '2') {*c = 0xab; return (2);}    /* 1/2 */
  60.     if (c1 == '3' && c2 == '4') {*c = 0xad; return (2);}    /* 3/4 */
  61.     if (c1 == 'd' && c2 == 'e') {*c = 0xf8; return (2);}    /* degree */
  62.     if (c1 == 'd' && c2 == 'g') {*c = 0xbb; return (2);}    /* dagger */
  63.     if (c1 == 'c' && c2 == 't') {*c = '$'; return (2);}    /* cent */
  64.     if (c1 == 'r' && c2 == 'g') {*c = 0xbe; return (2);}    /* registered */
  65.     if (c1 == 'c' && c2 == 'o') {*c = 0xbd; return (2);}    /* copyrite */
  66.     if (c1 == 't' && c2 == 'm') {*c = 0xbf; return (2);}    /* tm */
  67.     if (c1 == 's' && c2 == 'c') {*c = 0xdd; return (2);}    /* section */
  68.     if (c1 == 'a' && c2 == 'a') {*c = 0x27; return (2);}    /* acute */
  69.     if (c1 == 'g' && c2 == 'a') {*c = 0x60; return (2);}    /* grave */
  70.     if (c1 == 's' && c2 == 'l') {*c = '/'; return (2);}    /* slash */
  71.     if (c1 == '.' && c2 == '.') {*c = ':'; return (2);}    /* elipsis */
  72.     if (c1 == 'P' && c2 == 'P') {*c = 0xbc; return (2);}    /* para */
  73.     if (c1 == 'o' && c2 == 'q') {*c = '!'; return (2);}    /* open " */
  74.     if (c1 == 'c' && c2 == 'q') {*c = '\"'; return (2);}    /* close " */
  75.     if (c1 == 'd' && c2 == 'd') {*c = 0xba; return (2);}    /* dbl dagger */
  76.  
  77.  
  78.     /*
  79.      *   greek
  80.      */
  81.     if (c1 == '*' && c2 >= 'a' && c2 <= 'z')
  82.     {
  83.         /*
  84.          *   lower case
  85.          */
  86.         if (c2 == 'a') {*c = 'a'; return (2);}    /* alpha */
  87.         if (c2 == 'b') {*c = 'b'; return (2);}    /* beta */
  88.         if (c2 == 'g') {*c = 'g'; return (2);}    /* gamma */
  89.         if (c2 == 'd') {*c = 'd'; return (2);}    /* delta */
  90.         if (c2 == 'e') {*c = 'e'; return (2);}    /* epsilon */
  91.         if (c2 == 'z') {*c = 'z'; return (2);}    /* zeta */
  92.         if (c2 == 'y') {*c = 'y'; return (2);}    /* eta */
  93.         if (c2 == 'h') {*c = 'h'; return (2);}    /* theta */
  94.         if (c2 == 'i') {*c = 'i'; return (2);}    /* iota */
  95.         if (c2 == 'k') {*c = 'k'; return (2);}    /* kappa */
  96.         if (c2 == 'l') {*c = 'l'; return (2);}    /* lambda */
  97.         if (c2 == 'm') {*c = 'm'; return (2);}    /* mu */
  98.         if (c2 == 'n') {*c = 'n'; return (2);}    /* nu */
  99.         if (c2 == 'c') {*c = 'c'; return (2);}    /* xi */
  100.         if (c2 == 'o') {*c = 'o'; return (2);}    /* omicron */
  101.         if (c2 == 'p') {*c = 'p'; return (2);}    /* pi */
  102.         if (c2 == 'r') {*c = 'r'; return (2);}    /* rho */
  103.         if (c2 == 's') {*c = 's'; return (2);}    /* sigma */
  104.         if (c2 == 't') {*c = 't'; return (2);}    /* tau */
  105.         if (c2 == 'u') {*c = 'u'; return (2);}    /* upsilon */
  106.         if (c2 == 'f') {*c = 'f'; return (2);}    /* phi */
  107.         if (c2 == 'x') {*c = 'x'; return (2);}    /* chi */
  108.         if (c2 == 'q') {*c = 'q'; return (2);}    /* psi */
  109.         if (c2 == 'w') {*c = 'w'; return (2);}    /* omega */
  110.     }
  111.     if (c1 == '*' && c2 >= 'A' && c2 <= 'Z')
  112.     {
  113.         /*
  114.          *   upper case
  115.          */
  116.         if (c2 == 'A') {*c = 'A'; return (2);}    /* Alpha */
  117.         if (c2 == 'B') {*c = 'B'; return (2);}    /* Beta */
  118.         if (c2 == 'G') {*c = 'G'; return (2);}    /* Gamma */
  119.         if (c2 == 'D') {*c = 'D'; return (2);}    /* Delta */
  120.         if (c2 == 'E') {*c = 'E'; return (2);}    /* Epsilon */
  121.         if (c2 == 'Z') {*c = 'Z'; return (2);}    /* Zeta */
  122.         if (c2 == 'Y') {*c = 'Y'; return (2);}    /* Eta */
  123.         if (c2 == 'H') {*c = 'H'; return (2);}    /* Theta */
  124.         if (c2 == 'I') {*c = 'I'; return (2);}    /* Iota */
  125.         if (c2 == 'K') {*c = 'K'; return (2);}    /* Kappa */
  126.         if (c2 == 'L') {*c = 'L'; return (2);}    /* Lambda */
  127.         if (c2 == 'M') {*c = 'M'; return (2);}    /* Mu */
  128.         if (c2 == 'N') {*c = 'N'; return (2);}    /* Nu */
  129.         if (c2 == 'C') {*c = 'C'; return (2);}    /* Xi */
  130.         if (c2 == 'O') {*c = 'O'; return (2);}    /* Omicron */
  131.         if (c2 == 'P') {*c = 'P'; return (2);}    /* Pi */
  132.         if (c2 == 'R') {*c = 'R'; return (2);}    /* Rho */
  133.         if (c2 == 'S') {*c = 'S'; return (2);}    /* Sigma */
  134.         if (c2 == 'T') {*c = 'T'; return (2);}    /* Tau */
  135.         if (c2 == 'U') {*c = 'U'; return (2);}    /* Upsilon */
  136.         if (c2 == 'F') {*c = 'F'; return (2);}    /* Phi */
  137.         if (c2 == 'X') {*c = 'X'; return (2);}    /* Chi */
  138.         if (c2 == 'Q') {*c = 'Q'; return (2);}    /* Psi */
  139.         if (c2 == 'W') {*c = 'W'; return (2);}    /* Omega */
  140.     }
  141.  
  142.  
  143.     /*
  144.      *   box chars
  145.      */
  146.     if (c1 == 'L' && c2 >= 'a' && c2 <= 'k')
  147.     {
  148.         /*
  149.          *   single line
  150.          */
  151.         if (c2 == 'a') {*c = 0xd0; return (2);}    /**/
  152.         if (c2 == 'b') {*c = 0xd1; return (2);}    /**/
  153.         if (c2 == 'c') {*c = 0xd2; return (2);}    /**/
  154.         if (c2 == 'd') {*c = 0xd3; return (2);}    /**/
  155.         if (c2 == 'e') {*c = 0xd4; return (2);}    /**/
  156.         if (c2 == 'f') {*c = 0xd5; return (2);}    /**/
  157.         if (c2 == 'g') {*c = 0xd6; return (2);}    /**/
  158.         if (c2 == 'h') {*c = 0xd7; return (2);}    /**/
  159.         if (c2 == 'i') {*c = 0xd8; return (2);}    /**/
  160.         if (c2 == 'j') {*c = 0xd9; return (2);}    /**/
  161.         if (c2 == 'k') {*c = 0xda; return (2);}    /**/
  162.     }
  163.     if (c1 == 'L' && c2 >= 'A' && c2 <= 'Q')
  164.     {
  165.         /*
  166.          *   double line
  167.          */
  168.         if (c2 == 'A') {*c = 0xc0; return (2);}    /**/
  169.         if (c2 == 'B') {*c = 0xc1; return (2);}    /**/
  170.         if (c2 == 'C') {*c = 0xc2; return (2);}    /**/
  171.         if (c2 == 'D') {*c = 0xc3; return (2);}    /**/
  172.         if (c2 == 'E') {*c = 0xc4; return (2);}    /**/
  173.         if (c2 == 'F') {*c = 0xc5; return (2);}    /**/
  174.         if (c2 == 'G') {*c = 0xc6; return (2);}    /**/
  175.         if (c2 == 'H') {*c = 0xc7; return (2);}    /**/
  176.         if (c2 == 'I') {*c = 0xc8; return (2);}    /**/
  177.         if (c2 == 'J') {*c = 0xc9; return (2);}    /**/
  178.         if (c2 == 'K') {*c = 0xca; return (2);}    /**/
  179.         if (c2 == 'L') {*c = 0xcb; return (2);}    /**/
  180.         if (c2 == 'M') {*c = 0xcc; return (2);}    /**/
  181.         if (c2 == 'N') {*c = 0xcd; return (2);}    /**/
  182.         if (c2 == 'O') {*c = 0xce; return (2);}    /**/
  183.         if (c2 == 'P') {*c = 0xcf; return (2);}    /**/
  184.         if (c2 == 'Q') {*c = 0x80; return (2);}    /**/
  185.     }
  186.  
  187.  
  188.     /*
  189.      *   number super/subscripts
  190.      */
  191.     if (c1 == 'b' && c2 >= '0' && c2 <= '9')
  192.     {
  193.         if (c2 == '0') {*c = 0xa0; return (2);}    /* sub 0 */
  194.         if (c2 == '1') {*c = 0xa1; return (2);}    /* sub 1 */
  195.         if (c2 == '2') {*c = 0xa2; return (2);}    /* sub 2 */
  196.         if (c2 == '3') {*c = 0xa3; return (2);}    /* sub 3 */
  197.         if (c2 == '4') {*c = 0xa4; return (2);}    /* sub 4 */
  198.         if (c2 == '5') {*c = 0xa5; return (2);}    /* sub 5 */
  199.         if (c2 == '6') {*c = 0xa6; return (2);}    /* sub 6 */
  200.         if (c2 == '7') {*c = 0xa7; return (2);}    /* sub 7 */
  201.         if (c2 == '8') {*c = 0xa8; return (2);}    /* sub 8 */
  202.         if (c2 == '9') {*c = 0xa9; return (2);}    /* sub 9 */
  203.     }
  204.     if (c1 == 'p' && c2 >= '0' && c2 <= '9')
  205.     {
  206.         if (c2 == '0') {*c = 0x30; return (2);}    /* super 0 */
  207.         if (c2 == '1') {*c = 0x31; return (2);}    /* super 1 */
  208.